extends Item
class_name Weapon

# 子弹伤害
@export var damage : float
# 武器冷却
@export var cooldown : float
# 子弹运行速度
@export var speed : float
# 可升级的武器属性列表
@export var upgrades : Array[Upgrade]
# 加载子弹场景
@export var projectile_node : PackedScene = preload("res://Scenes/Projectile.tscn")
# 进化所需物品的属性
@export var item_needed : PassivelItem
# 升级后的武器
@export var evolution : Weapon
#插槽的引用
var slot

# 这是一个抽象方法!
func activate(_resource,_target,_scene_tree):
	pass

func is_upgradable()-> bool:
	if level <= upgrades.size():
		return true
	else:
		return false

func upgrade_item()->void:
	if not is_upgradable():
		return
	var upgrade = upgrades[level - 1]
	damage += upgrade.damage
	cooldown += upgrade.cooldown
	speed += upgrade.speed
	level += 1

# 检查物品是否到达其最大等级
func max_level_reached()->bool:
	if upgrades.size() + 1 == level && upgrades.size() != 0:
		return true
	return false
		
